<template>
  <div class="keyborad">
    <div class="key_main" :style="{transform:show?'translateY(0)':'translateY(100%)'}">
      <div class="main_title">
        <img src="../../assets/images/del_1.png" @click="hideFun">
        <span>请输入支付密码</span>
      </div>
      <div class="main_content">
        <div class="content_num">
          <div v-for="item in 6" :key="item" class="content_item">{{password[item-1] ? '●' :''}}</div>
        </div>
      </div>
      <div class="main_keyboard">
        <div class="key_num" v-for="item in 9" :key="item" @click="inputNumFun({num:item})">{{item}}</div>
        <div class="key_null"></div>
        <div class="key_0" @click="inputNumFun({num:0})">0</div>
        <div class="key_del" @click="delNumFun">
          <img src="../../assets/images/del_2.png">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    show_key: Boolean,
  },
  computed: {},
  data () {
    return {
      password: '',//密码
      show: false,
    }
  },
  methods: {
    forgotPassword () {
      uni.navigateTo({
        url: `/pages/login/paymentPwd?type=pay`
      })
    },
    inputNumFun (op) {
      let _this = this
      if (_this.password.length <= 6) {
        _this.password += op.num
        if (_this.password.length === 6) {
          _this.$emit('getPassword', { password: _this.password })
        }
      }

    },
    delNumFun () {
      if (this.password.length == 0) return
      this.password = this.password.substring(0, this.password.length - 1)
    },
    hideFun () {
      this.password = ''
      this.show = false
      this.$emit('hideFun')
    }
  },
  mounted () {
    setTimeout(() => {
      this.show = this.show_key
    }, 0)
  }
}
</script>

<style scoped>
.keyborad {
  width: 100vw;
  position: fixed;
  bottom: 0px;
  background-color: rgba(0, 0, 0, 0.4);
  top: 0px;
  left: 0px;
  right: 0px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform 0.4s;
}

.keyborad .key_main {
  background: #fff;
  width: 100vw;
  height: 420px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.4s;
}
.main_title {
  font-size: 18px;
  color: #000000;
  height: 100rpx;
  display: flex;
  align-items: center;
  letter-spacing: 1px;
  width: 100%;
  box-sizing: border-box;
  padding: 0px 10px;
  border-bottom: 1px solid #e1e1e1;
}
.main_title img {
  width: 24px;
  height: 24px;
}
.main_title span {
  flex: 1;
  /* margin-left: -24px; */
  display: flex;
  justify-content: center;
  height: 60px;
  line-height: 60px;
}
.main_content {
  width: 100%;
  box-sizing: border-box;
  padding: 0px 15px;
}
.content_num {
  width: 100%;
  height: 50px;
  border: 1px solid #dbdbdb;
  border-radius: 5px;
  display: flex;
  align-items: center;
}
.content_item {
  flex: 1;
  height: 100%;
  border-right: 1px solid #dbdbdb;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 22px;
}
.content_item:last-child {
  border-right: none;
}
.main_forget {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  font-size: 14px;
  color: #007aff;
  margin-top: 20px;
}
.main_keyboard {
  width: 100%;
  height: 280px;
  background: #ffffff;
  display: flex;
  flex-flow: wrap;
  border-top: 1px solid #f1f4f4;
}
.key_null,
.key_del {
  background: #e2e7eb;
}
.key_del img {
  width: 34px;
  height: 34px;
}
.key_num,
.key_null,
.key_del,
.key_0 {
  width: 33.3%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.key_num {
  border-right: 1px solid #f1f4f4;
  border-bottom: 1px solid #f1f4f4;
  box-sizing: border-box;
  font-size: 20px;
}
.key_num:nth-child(8) {
  border-bottom: none;
}
.key_0 {
  border-top: 1px solid #f1f4f4;
  font-size: 20px;
}
</style>
